﻿using System;

namespace ProjectMain
{
    public class EmployeeVacations
    {

        public static void EmployeeVacationsOptions(string username)
        {
            System.Console.WriteLine("\nWhat would you like to do........\n");

            System.Console.WriteLine("1. Add your vacations");
            System.Console.WriteLine("2. Edit your vacations");
            System.Console.WriteLine("3. View all vacations");
            System.Console.WriteLine("4. View your vacations");
            System.Console.WriteLine("5. Go to the previous menu\n");


            System.Console.WriteLine("Please enter of the following options \n");

            // input from the user

            // Based on that, write another function which call spcific Options
            System.Console.Write("Your Option: ");

            int EmployeeVacationUserInput = Int32.Parse(System.Console.ReadLine());


            switch ((EmployeeVacationUserInput))
            {
                case 1:

                    AddVacations(username);
                    EmployeeVacationsOptions(username);

                    break;

                case 2:

                    ModifyVacations(username);
                    EmployeeVacationsOptions(username);

                    break;


                case 3:

                    ViewAlVacations(); EmployeeVacationsOptions(username); 
                    SubMenu.SubMenuOptions(username);
                    break;

                case 4:

                    ViewYourVacations(username);
                    EmployeeVacationsOptions(username);
                    break;

                case 5:

                    SubMenu.SubMenuOptions(username);
                    break;

            }



        }

        public static void AddVacations(string username)
        {
            Console.WriteLine("Add your vacations............");

            Console.WriteLine("Start Date");
            DateTime startdate = DateTime.Parse(Console.ReadLine());
            System.Console.WriteLine("End Date");
            DateTime enddate = DateTime.Parse(Console.ReadLine());

            // start date can not be less than end date
            // string username = "nk";

            // make a call to the database


            DBClass.DBConnAndAddVacations(username, startdate, enddate);


        }




        public static void ModifyVacations(string username)
        {
            Console.WriteLine("Modify your vacations............");

            Console.WriteLine(" Current Start Date");
            string startdate = Console.ReadLine();
            
            System.Console.WriteLine("Current End Date");
            string enddate = Console.ReadLine();

            // string enddate = DateTime.Parse(Console.ReadLine());

            Console.WriteLine(" New Start Date");
            string newstartdate = Console.ReadLine();


            System.Console.WriteLine("New End Date");
            string newenddate = Console.ReadLine();

            // start date can not be less than end date
            // string username = "nk1";

            // make a call to the database


            DBClass.DBConnAndModifyVacation(username, startdate, enddate, newstartdate, newenddate);


        }


        public static void ViewAlVacations()
        {
            DBClass.DBConnAndViewAllVacations();
        }


        public static void ViewYourVacations(string username)
        {
            DBClass.DBConnAndViewYourVacations(username);
        }

        



    }
}